<template>
  <div style="text-align:center;margin-top:200px">
    <el-link type="primary">亲~！请先填写申请信息，审核通过即可开始经营</el-link>
    <el-button type="success " @click="dialogFormVisible = true">申请</el-button>

    <el-dialog title="请填写信息" :visible.sync="dialogFormVisible">
      <el-form ref="form" :model="form">
        <el-form-item label="供应商名字：" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="所在地：" :label-width="formLabelWidth">
          <el-input v-model="form.addr" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="联系电话：" :label-width="formLabelWidth">
          <el-input v-model="form.phone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="您的网址：" :label-width="formLabelWidth">
          <el-input v-model="form.web" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="展示信息：" :label-width="formLabelWidth">
          <el-input v-model="form.note" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="subBtn">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { addSupplier } from "@/api/admin";
import { mapState } from "vuex";
export default {
  data() {
    return {
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        name: "", //店名
        addr: "", //地址
        phone: "",
        web: "", //网址
        img: "", //头像
        note: "", //备注
        supplierId:""
      },
      formLabelWidth: "120px"
    };
  },
  computed: {
    ...mapState("user", ["_id"])
  },
  created() {
    this.form.supplierId = this._id;
  },
  methods: {
    async subBtn() {
      addSupplier(this.form).then(res => {
        if (res.data.ok) {
          this.dialogFormVisible = false;
          this.$router.go(0);
        }
      });
    }
  }
};
</script>

<style>
</style>